import {
  Body,
  Controller,
  Get,
  Patch,
  UseGuards,
} from '@nestjs/common';
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import {
  GlobalConfigAdminUpdateDto,
} from './global-config.dto';
import { GlobalConfigService } from './global-config.service';
import { GlobalConfigAdminShowResult } from "@/module/global-config/global-config.result";
import { AdminAuthGuard } from "@/common/auth/admin-auth.guard";

@Controller('/v1/admin/global-configs')
@ApiTags('GlobalConfig_admin')
@UseGuards(AdminAuthGuard)
export class GlobalConfigV1AdminController {
  constructor(private readonly globalConfigService: GlobalConfigService) {
  }

  @Get('/unique')
  @ApiOperation({ summary: '获取配置列表' })
  @ApiOkResponse({ type: GlobalConfigAdminShowResult })
  async show(): Promise<GlobalConfigAdminShowResult> {
    const res = await this.globalConfigService.adminShow();
    return res;
  }

  @Patch('/unique')
  @ApiOperation({ summary: '修改配置' })
  async update(
    @Body() body: GlobalConfigAdminUpdateDto,
  ): Promise<void> {
    await this.globalConfigService.adminUpdate(body);
    return;
  }
}
